package cn.edu.scau.cmi.wujiaxian.exercise11;

import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class WindowMouse extends JFrame{
	private static final long serialVersionUID = 4174621914605686809L;

	JTextField text;
	JButton button;
	JTextArea textArea;
	MousePolice police;
	
	public WindowMouse() {
		init();
		setVisible(true);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	
	void init() {
		setLayout(new FlowLayout());
		text = new JTextField(8);
		textArea = new JTextArea(5, 28);
		police = new MousePolice();
		police.setJTextArea(textArea);
		text.addMouseListener(police);
		button = new JButton("按钮");
		button.addMouseListener(police);
		addMouseListener(police);
		add(button);
		add(text);
		add(textArea);
	}
	
}
